package com.zemo.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.tgb.entity.User;
import com.zemo.entity.Comment;
import com.zemo.entity.Product;
import com.zemo.service.CommentService;
import com.zemo.service.ProductService;

/**
 * @ClassName: ProductController
 * @author: SuperZemo
 * @date: Mar 31, 2014 2:09:24 AM
 * @email:chenzeming@lanbaoo.com
 * @Description: 评论相关
 */
@Controller
@RequestMapping("/comment")
public class CommentController {

	@Autowired
	private CommentService commentService;
	
	@RequestMapping("/list")
	public ModelAndView listComment(){
		List<Comment> comments = commentService.listAllComment();
		
		return new ModelAndView("comments","comments",comments);
	} 
	
	 /*
     * 进行添加商品评价，进入添加界面
     */   
    @RequestMapping("/toAddcomment")  
    public String toAddComment(){  
        return "add-comment";  
    }  
    /*
     * 添加数据，结果返回给/comment/list
     */    
    @RequestMapping("/addComment")  
    public String addUser(Comment comment,HttpServletRequest request){  
          
        commentService.addComment(comment); 
          
        return "redirect:/comment/list";  
    }  
	
}
